<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page language="java" contentType="text/html"%>
<%@ page import="java.sql.*"%>
<%@ page import="com.microsoft.sqlserver.jdbc.*"%>

<html>
<body>
<b>KamiKayaKreasi MO Receiver</b><p></p><p></p><p></p><p></p>
<%
	String connectionUrl = "jdbc:sqlserver://localhost:14333;databaseName=bizring";
	String userid = "sa";
	String passwd = "qlalf@sql";

	// Declare the JDBC objects.
	Connection con = null;
	Statement stmt = null;
	ResultSet rs = null;

	// Establish the connection.
	Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

	// Insert Data
	String msisdn = request.getParameter ("msisdn");
	String trx_id = request.getParameter ("trx_id");
	String sms = request.getParameter ("sms");
	String ipaddr = request.getRemoteAddr();

	String SQL =	"INSERT INTO rcv_tsel (msisdn, trx_id, sms, ipaddress) " +
					"     VALUES ('" + msisdn + "', '" + trx_id + "', '" + sms + "', '" + ipaddr + "')";
	try {   
			con = DriverManager.getConnection(connectionUrl, userid, passwd);
			stmt = con.createStatement();
        int result = stmt.executeUpdate(SQL);   

		System.out.println(result+" Rows Inserted...");

    } catch (SQLException e) {   
        e.printStackTrace();   
    } finally{   
        try {   
            if(stmt !=null) stmt.close();   
            if(con !=null) con.close();   
        } catch (SQLException e) {   
            e.printStackTrace();   
        }   
    }   

	// Create and execute an SQL statement that returns some data.
	SQL = "SELECT TOP 1 * FROM rcv_tsel where id = (select max (id) from rcv_tsel)";

			con = DriverManager.getConnection(connectionUrl, userid, passwd);
         stmt = con.createStatement();
		    rs = stmt.executeQuery(SQL);

	// Iterate through the data in the result set and display it.
	while (rs.next()) {
		out.println(rs.getString(1)+ " " + rs.getString(2)+ " " + rs.getString(3)+ " " + 
					rs.getString(4)+ " " + rs.getString(5)+ " " + rs.getString(6)+ "<br/>");
	}

	if (rs != null) try { rs.close(); } catch(Exception e) {}
	if (stmt != null) try { stmt.close(); } catch(Exception e) {}
	if (con != null) try { con.close(); } catch(Exception e) {}
%>

<br/><br/>
Complete !!!

</body>
</html>

